package com.zyz.K_集合.collection接口;

import java.util.ArrayList;
import java.util.Collection;

/**
 * @author: vick
 * @Date: 2025/3/27
 * @Description:
 * @version: 1.0
 */
public class TestCollectionContains {
    public static void main(String[] args) {
        Collection collection = new ArrayList();
        System.out.println("collection添加元素之前，isEmpty = " + collection.isEmpty());
        collection.add(111);
        collection.add(111);
        collection.add(111);
        collection.add(222);
        collection.add("vick");
        collection.add(new String("aaaa"));
        System.out.println("c1集合元素的个数：" + collection.size());
        System.out.println("collection添加元素之后，isEmpty = " + collection.isEmpty());

        System.out.println("=====");

        Collection collection2 = new ArrayList();
        collection2.add(111);
        collection2.add(222);
        collection2.add("vick");
        System.out.println(collection2);
        System.out.println("collection2 是否包含 vick ：" + collection2.contains("vick"));
        System.out.println("collection2 是否包含 333 ：" + collection2.contains("333"));


        System.out.println("=====");
        Collection collection3 = new ArrayList();
        collection3.add(222);
        collection3.add("vick");
        System.out.println("collection3的元素是否在 collection2 中 都存在 （collection3是collection2的 子集）" + collection2.containsAll(collection3));
    }
}
